import 'package:flutter/material.dart';

class BottomInputDialog extends StatelessWidget {
  final String? title;
  final Function(String) confirm;
  final TextInputType type;
  final FocusNode? commentFocus;
  final TextEditingController textEditingController;
  final int? maxLength;
  final String? placeholder;

  const BottomInputDialog({
    super.key,
    this.title,
    required this.type,
    required this.confirm,
    required this.textEditingController,
    this.maxLength,
    this.placeholder,
    this.commentFocus,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: Column(
        children: <Widget>[
          Expanded(
            child: GestureDetector(
              child: Container(color: Colors.black54),
              onTap: () {
                Navigator.pop(context);
              },
            ),
          ),
          Container(
            height: 50,
            color: Colors.white,
            padding: const EdgeInsets.symmetric(horizontal: 15),
            child: Row(
              children: <Widget>[
                Text('${placeholder ?? 'Place Enter'}:'),
                Expanded(
                  flex: 1,
                  child: Container(
                    padding: const EdgeInsets.symmetric(horizontal: 6),
                    margin: const EdgeInsets.symmetric(horizontal: 6),
                    decoration: BoxDecoration(
                      border: Border(
                        bottom: BorderSide(
                          width: .5,
                          color: Colors.grey[400] ?? const Color(0x00eeeeee),
                        ),
                      ),
                    ),
                    child: TextField(
                      controller: textEditingController,
                      autofocus: true,
                      keyboardType: type,
                      textInputAction: TextInputAction.done,
                      maxLength: maxLength,
                      decoration: InputDecoration(
                        hintText: 'Please enter $title',
                        hintStyle: const TextStyle(
                          color: Colors.grey,
                          fontSize: 13,
                        ),
                        contentPadding: const EdgeInsets.symmetric(vertical: 6),
                        border: InputBorder.none,
                      ),
                      onSubmitted: (value) {
                        confirm(value);
                        Navigator.pop(context);
                      },
                    ),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
